package edu.calvin.djs32.cs214.interpreters.height;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

import edu.calvin.cs214.hobbes2008.IntegerTIR;
import edu.calvin.cs214.hobbes2008.StringTIR;
import edu.calvin.cs214.hobbes2008.TupleTIR;



public class HeightTest {
	private Height myHeight;
	
	@Before
	public void setUp() {
		myHeight = new Height();
	}
	
	@Test
	public void integerShouldBe0(){
		assertEquals(0, myHeight.visitInteger(new IntegerTIR(1)));
		assertEquals(0, myHeight.visitInteger(new IntegerTIR(1000)));
		assertEquals(0, myHeight.visitInteger(new IntegerTIR(-1)));
	}
	
	@Test
	public void stringShouldBe0(){
		assertEquals(0, myHeight.visitString(new StringTIR("foo")));
		assertEquals(0, myHeight.visitString(new StringTIR("bar")));
		assertEquals(0, myHeight.visitString(new StringTIR("foo bar")));
	}
	
	@Test
	public void tupleShouldBe1(){
		assertEquals(1, myHeight.visitTuple(new TupleTIR()));
		assertEquals(2, myHeight.visitTuple(new TupleTIR(new TupleTIR())));
		assertEquals(4, myHeight.visitTuple(new TupleTIR(new TupleTIR(new TupleTIR(new TupleTIR())))));
	}
	
	@Test
	public void shouldDoMixes(){
		assertEquals(1, myHeight.visitTuple(new TupleTIR(new IntegerTIR(1), new IntegerTIR(2), new StringTIR("foo"))));
		assertEquals(3, myHeight.visitTuple(
				new TupleTIR(new IntegerTIR(1), 
				new TupleTIR(new TupleTIR(new IntegerTIR(2)), new IntegerTIR(3)))));
	}
}
